package com.hz.mybatistest.mapper;

import com.hz.mybatistest.model.entiy.UserEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper {

    @Select("select * from users where id = #{id}")
    public UserEntity findById(@Param("id") int id);

    @Select("select * from users where username=#{username};")
    public UserEntity findUserByUsername(@Param("username") String username);
    @Select("select * from users;")
    public List<UserEntity> findAll();

    @Insert("insert into users values (null, #{username},#{realname},#{student_id},#{pwd_salt},#{pwd},#{pwd_valid_date},#{user_type},#{pwd_error_count},#{class_id},#{grade_id})")
    public void addUser(UserEntity userEntity);


    @Delete("delete from users where id = #{id}")
    public void deleteUserById(int id);

}
